{% extends "admin/base_site.html" %}
{% load i18n admin_static %}
{% load url from future %}

{% block css_commons %}{% endblock css_commons %}

{% block extrastyle %}
    {{ block.super }}
    <link rel="stylesheet" type="text/css" href="{% static "admin/css/login.css" %}" />
{% endblock %}

{% block bodyclass %}login{% endblock %}

{% block branding %}{% endblock %}

{% block nav-global %}{% endblock %}

{% block content_title %}{% endblock %}

{% block breadcrumbs %}{% endblock %}

{% block content %}
<div id="content-main">
    <div class="row-fluid">
        <div class="well span6 well-wrapper-form">
            <img class="img-circle logo-admin" src="/static/img/logo.png" alt="{{ site.name }}">
            <form class="bs-docs-example form-inline" id="login-form" action="{{ app_path }}" method="post">
                {% csrf_token %}
                <fieldset>
                    <legend>
                        Administracja Multimedio - {{ title }}
                    </legend>
                    {% if form.errors and not form.non_field_errors and not form.this_is_the_login_form.errors %}
                        <p class="errornote alert alert-error fade in">
                            <button data-dismiss="alert" class="close" type="button">×</button>
                            {% blocktrans count form.errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
                        </p>
                    {% endif %}
                    {% if form.non_field_errors or form.this_is_the_login_form.errors %}
                        {% for error in form.non_field_errors|add:form.this_is_the_login_form.errors %}
                            <p class="errornote alert alert-error fade in">
                            <a href="#" data-dismiss="alert" class="close">×</a>
                                {{ error }}
                            </p>
                        {% endfor %}
                    {% endif %}
                    <div class="control-group {% if form.username.errors %}error{% endif %}">
                        <input type="text" placeholder="{% trans 'Username' %}" class="span4" name="{{ form.username.html_name }}" id="{{ form.username.html_name }}" class=" focused" value="{% firstof form.username.value "" %}">
                    </div>
                    <div class="control-group {% if form.password.errors %}error{% endif %}">
                        <input type="password" placeholder="{% trans 'Password' %}" class="span4" name="{{ form.password.html_name }}" id="{{ form.password.html_name }}" value="">
                    </div>
                    <input type="hidden" name="this_is_the_login_form" value="1" />
                    <input type="hidden" name="next" value="{{ next }}" />
                    <input class="btn btn-primary" type="submit" value="{% trans 'Log in' %}">
                </fieldset>
            </form>
            {% url 'admin_password_reset' as password_reset_url %}
            {% if password_reset_url %}
                <p class="forgotten-password">
                    <a href="{{ password_reset_url }}">
                        {% trans 'Forgotten your password or username?' %}
                    </a>
                </p>
            {% endif %}
            <p class="link-site-name">
                <a href="http://{{ site }}">
                    {{ site.name }}
                </a>
            </p>
        </div>
    </div>
</div>
{% endblock %}

{% block js_footer %}
    <script type="text/javascript">
    (function ($) {
        $(document).ready(function(){
            {% if not form.this_is_the_login_form.errors %}
                {% if form.username.errors %}
                    user = $("#username");
                    user.popover({
                        'placement' : 'top',
                        'title' : '<i class="icon-user"></i> {% trans 'Username' %}',
                        'content' : '{{ form.username.errors }}',
                        'trigger': 'focus'
                    }).keydown(function(){user.popover('hide');});
                {% endif %}
                {% if form.password.errors %}
                    pass = $("#password");
                    pass.popover({
                        'placement' : 'bottom',
                        'title' : '<i class="icon-lock"></i> {% trans 'Password' %}',
                        'content' : '{{ form.password.errors }}',
                        'trigger': 'focus'
                    }).keydown(function(){pass.popover('hide');});
                {% endif %}
                {% if not form.username.errors and not form.password.errors %}
                    $('#username').focus();
                {% endif %}
            {% endif %}
        });
    })(django.jQuery);
    </script>
{% endblock js_footer %}
